package com.i.piccommon.constant;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author lewis
 * @type class
 * @description
 * @since 2024/10/23
 */


@Data
@Accessors(chain = true)
public class ApiResponse<T> {
    public Integer code;
    private T data;
    private String message;

    public ApiResponse(Integer code, T data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public ApiResponse(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
    public static <T> ApiResponse<T> ok(T data) {
        return new ApiResponse<>(Status.OK.getCode(), data, Status.OK.getMessage());
    }
    public static <T> ApiResponse<T> ok(T data,String message) {
        return new ApiResponse<>(Status.OK.getCode(), data, message);
    }
    public static <T> ApiResponse<T> fail(){
        return new ApiResponse<>(Status.FAIL.getCode(),Status.FAIL.getMessage());
    }
    public static <T> ApiResponse<T> fail(String message){
        return new ApiResponse<>(Status.FAIL.getCode(),message);
    }

}
